<?php

/**
 * description
 */
class BackendPollFormFilter extends PollFormFilter
{
	/**
	 * description
	 */
	public function configure()
	{
    $this->widgetSchema['contestant']    = new sfWidgetFormInputText();
    $this->validatorSchema['contestant'] = new sfValidatorPass();

    $this->widgetSchema['hits_greater_than']    = new sfWidgetFormInputText();
    $this->validatorSchema['hits_greater_than'] = new sfValidatorPass();

    $this->widgetSchema['hits_less_than']    = new sfWidgetFormInputText();
    $this->validatorSchema['hits_less_than'] = new sfValidatorPass();
	}

  public function addContestantColumnQuery($query, $field, $values)
  {
    $query->addWhere('c.name like ?', "%$values%");
  }

  public function addHitsGreaterThanColumnQuery($query, $fields, $values)
  {
    $rootAlias = $query->getRootAlias();

    $query->addWhere("$rootAlias.hits > ?", $values);
  }

  public function addHitsLessThanColumnQuery($query, $fields, $values)
  {
    $rootAlias = $query->getRootAlias();

    $query->addWhere("$rootAlias.hits < ?", $values);
  }
}
